<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // 封装一个数学对象，里面有 PI, 求数组的最大值和最小值
        let myMath = {
            PI: 3.14,
            getMax: function (arr) {
                let max = arr[0];
                for (let index in arr) {
                    if (arr[index] > max) {
                        max = arr[index];
                    }
                }
                return max;
            },
            getMin: function (arr) {
                let min = arr[0];
                for (let index in arr) {
                    if (arr[index] < min) {
                        min = arr[index];
                    }
                }
                return min;
            }
        }

        console.log(myMath.PI);
        let arr = [2, 12, 5, 3];
        console.log(myMath.getMax(arr));
        console.log(myMath.getMin(arr));
    </script>
</head>

<body>

</body>